import 'package:bruno/bruno.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../common/index.dart';
import '../index.dart';

class ApplicationPage extends GetView<ApplicationController> {
  ApplicationPage({Key? key}) : super(key: key);

  final List<Map> barItemList = [
    {'title': '首页', 'icon': '', 'activeIcon': ''},
    {'title': '技师', 'icon': '', 'activeIcon': ''},
    {'title': '订单', 'icon': '', 'activeIcon': ''},
    {'title': '我的', 'icon': '', 'activeIcon': ''},
  ];

  // // 主视图
  // Widget _buildView() {
  //   return const HelloWidget();
  // }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ApplicationController>(
      builder: (_) {
        return Scaffold(
          body: Obx(() => IndexedStack(
                index: controller.state.tabbarCurrentIndex,
                children: const [
                  HomePage(),
                  TaskPage(),
                  StationPage(),
                  MinePage()
                ],
              )),
          bottomNavigationBar: Obx(() => BrnBottomTabBar(
                items: barItemList
                    .map((item) => BrnBottomTabBarItem(
                        title: Text(item['title']),
                        icon: CachedNetworkImage(
                          imageUrl: demoImg,
                          width: 24,
                          height: 24,
                          fit: BoxFit.cover,
                        ),
                        activeIcon: CachedNetworkImage(
                          imageUrl: demoImg2,
                          width: 24,
                          height: 24,
                          fit: BoxFit.cover,
                        )))
                    .toList(),
                fixedColor: AppColor.mainColor,
                currentIndex: controller.state.tabbarCurrentIndex,
                type: BrnBottomTabBarDisplayType.fixed,
                iconSize: 14,
                isAnimation: false,
                isInkResponse: false,
                badgeColor: Colors.red,
                onTap: (value) {
                  controller.state.tabbarCurrentIndex = value;
                  print(value);
                },
              )),
        );
      },
    );
  }
}
